package com.example.storageservice.dao;

import com.example.storageservice.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * program: springcloud-seata
 * description:
 * author: Mr.Yiu
 * create: 2021-05-20 16:46
 **/
@Mapper
public interface ProductMapper {
    @Select("SELECT id,`name`,price,num FROM product")
    List<Product> findProductList();

    @Select("SELECT id,`name`,price,num FROM product where id=#{id}")
    Product findProduct(@Param("id") int id);

    @Update("update product set num=(num-#{num}) where id=#{id}")
    int update(@Param("id") int id, @Param("num") int num);
}
